<?php

use yii\db\Migration;

/**
 * Handles the creation of table `{{%common_attachment}}`.
 */
class m190430_014014_create_common_attachment_table extends Migration
{
    /**
     * {@inheritdoc}
     */
    public function safeUp()
    {
        $this->createTable('{{%common_attachment}}', [
            'id' => $this->primaryKey(),
            'drive' => $this->string(50)->defaultValue('')->comment('驱动'),
            'upload_type' => $this->string(10)->defaultValue('')->comment('上传类型'),
            'specific_type' => $this->string(100)->defaultValue('')->comment('类别'),
            'base_url' => $this->string(100)->defaultValue('')->comment('url'),
            'path' => $this->string(100)->defaultValue('')->comment('本地路径'),
            'name' => $this->string(100)->defaultValue('')->comment('文件原始名'),
            'extension' => $this->string(50)->defaultValue('')->comment('扩展名'),
            'size' => $this->integer()->defaultValue(0)->comment('大小'),
            'year' => $this->integer()->defaultValue(0)->comment('年'),
            'month' => $this->integer()->defaultValue(0)->comment('月'),
            'day' => $this->integer()->defaultValue(0)->comment('日'),
            'upload_ip' => $this->string(20)->defaultValue('')->comment('上传IP'),
            'status' => $this->tinyInteger(4)->notNull()->defaultValue(1)->comment('状态 0 禁用 1 启用'),
            'created_at' => $this->integer()->comment('创建时间'),
            'updated_at' => $this->integer()->comment('更新时间'),
        ]);
    }

    /**
     * {@inheritdoc}
     */
    public function safeDown()
    {
        $this->dropTable('{{%common_attachment}}');
    }
}
